<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>打印二维码</title>
		<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
		<style type="text/css">
			.button-div{
				height: 60px;
				width: 650px;
				margin: auto;
				text-align: center;
				line-height: 60px;
			}
			.button-submit{
				display: inline-block;
				height: 38px;
				line-height: 38px;
				padding: 0 18px;
				background-color: #009688;
				color: #fff;
				white-space: nowrap;
				text-align: center;
				font-size: 14px;
				border: none;
				border-radius: 2px;
				cursor: pointer;
			}
			.return{
				border: 1.5px solid #bdbdbd;
				background-color: #fff;
				border-color: #e6e6e6;
				color: #666;
			}

			.gig-div{
				height: 100%;
				width: 500px;
				margin: auto;
			}
			.margin{
				width: 96%;
				height: 280px;
				margin: auto auto 20px auto;
				background-color: #ededee;
			}
			.title-div{
				height: 20%;
				width: 100%;
				text-align: center;
				padding-top: 5px;
			}
			.title-text{
				font-size: 30px;
				font-weight: 600;
				text-align: center;
			}
			.note-div{
				height: 80%;
				width: 100%;
				background-color: #ededee;
				margin: 0 auto; /* 添加这一行 */
			}
			.left-div{
				float:left;
				height: 210px;
				width: 40%;
				background-color: #ededee;
				border-right:1px solid #000;
				text-align: center;
			}
			.right-div{
				float:right;
				height: 210px;
				width: 55%;
				background-color: #ededee;
				background-color: #ededee;

			}
			.img1{
				margin-left:10px;
				width: 170px;
				height: 140px;
				padding-bottom:10px;
			}
			.img2{
				width: 380px;
				height: 100px;
			}
			.left-div-div1{
				margin-left:10px;
				height: 15%;
				font-weight: 600;
				font-size: 22px;
			}
			.left-div-div2{
				margin-left:10px;
				height: 15%;
			}
			.left-div-div3{
				height: 70%;
				font-weight: 600;
			}
			.right-div-div{
				height: 13%;

			}
			.right-div-div-big{
				height: 20%;
				font-size:22px;
				font-weight: 600;
			}
			.right-div-div-big_img{
				height: 30%;
				font-weight: 600;
			}
			.right-div-div-sm{
				height: 10%;
				text-align: center;
			}
		</style>
	</head>
	<body>
		<div class="button-div">
			<button class="button-submit" type="button" onclick="printing()">&emsp;打印&emsp;</button>
			<button class="button-submit" type="button" onclick="queding()">&emsp;确定&emsp;</button>
			<button class="button-submit return" type="button" onclick="backupPage()">&emsp;关闭&emsp;</button>
		</div>
		<div class="gig-div" id="printinghtml">
			<div class="margin">
				<div class="title-div">
					<span class="title-text">12QSD8314七度空间少女特薄迷你巾12包小箱装卫生巾（B2B专供）</span>
				</div>
				<div class="note-div">
					<div class="left-div">
						<div class="left-div-div1"><span>CS1-66666</span></div>
						<div class="left-div-div2"><span>坚果类S</span></div>
						<div class="left-div-div3">
							<img class="img1" src="/hxStoragePutDetailed/getqrcode?id=CS1-66666">
						</div>
					</div>
					<div class="right-div">
						<div class="right-div-div"><span>编号：AAC00117</span></div>
						<div class="right-div-div"><span>规格：10斤</span></div>
						<div class="right-div-div"><span>配送单位：箱</span></div>
						<div class="right-div-div-big"><span>2023-05-28</span></div>
						<div class="right-div-div-big-img"><img class="img2" src="/hxStoragePutDetailed/getCode_128?id=695454548484170"></div>
						<div class="right-div-div-sm"><span>695454548484170</span></div>
					</div>
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript">
		function getUrlParam(name) {
		    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
		    var r = window.location.search.substr(1).match(reg);
		    if (r != null) {
		        return unescape(r[2]);
		    } else {
		        return null;
		    }
		};

		var str = getUrlParam("ids")
		//字符串截取为数组
		var strArr = str.split(",");
		var arr = []
		for(j = 0,len = strArr.length; j < len; j++) {
			arr.push(strArr[j])
		};
		var printQuantity = getUrlParam("printQuantity")

		var html = ''
		for (var i=0;i<arr.length;i++){
			$.ajax({
				type: 'get',
				data: {id:arr[i]},
				url: "/hxBasicGoods/details",
				async: false,
				dataType:"json",
				success: function (data) {
					if(data.data != null && data.data != ''){
						 console.log(data.data)
						if(printQuantity == null || printQuantity == '' || typeof parseFloat(printQuantity) != 'number' ||  parseFloat(printQuantity) <= 0){
							// for (var j=0;j<data.data.num;j++){
								html += '<div class="margin">'+
										'<div class="title-div">'+
										'<span class="title-text"><strong>'+data.data.goodsName+'</strong></span>'+
									'</div>'+
									'<div class="note-div">'+

										'<div class="right-div-div"><span><strong>商品代码：'+data.data.goodsNumber+'</strong></span></div>'+
										'<div class="right-div-div"><span><strong>规格：'+data.data.goodsSpecs+'</strong></span></div>'+
										'<div class="right-div-div"><span><strong>配送单位：'+data.data.psUnit+'</strong></span></div>'+
											'<div class="right-div-div-big-img"><img class="img2" src="/hxStoragePutDetailed/getCode_128?id='+data.data.goodsPcode69+'"></div>'+
											'<div class="right-div-div-sm"><span>'+data.data.goodsPcode69+'</span></div>'+

									'</div>'+
								'</div>';
							// }
						} else {
							// for (var j=0;j<printQuantity;j++){
							html += '<div class="margin">'+
									'<div class="title-div">'+
									'<span class="title-text"><strong>'+data.data.goodsName+'</strong></span>'+
									'</div>'+
									'<div class="note-div">'+

									'<div class="right-div-div"><span><strong>编号：'+data.data.goodsNumber+'</strong></span></div>'+
									'<div class="right-div-div"><span><strong>规格：'+data.data.goodsSpecs+'</strong></span></div>'+
									'<div class="right-div-div"><span><strong>配送单位：'+data.data.psUnit+'</strong></span></div>'+
									'<div class="right-div-div-big-img"><img class="img2" src="/hxStoragePutDetailed/getCode_128?id='+data.data.goodsPcode69+'"></div>'+
									'<div class="right-div-div-sm"><span>'+data.data.goodsPcode69+'</span></div>'+

									'</div>'+
									'</div>';
							// }
						}
					}
				}
			})
		}
		$("#printinghtml").html(html)
	    //返回按钮
	    function backupPage(){
	    	var Index = parent.layer.getFrameIndex(window.name);
	        parent.layer.close(Index);
	    }
		function queding(){
			$.ajax({
				type: 'get',
				data: {ids:getUrlParam("ids")},
				url: "/hxStoragePutDetailed/btnEditPrint",
				async: false,
				dataType:"json",
				success: function (data) {
					parent.submit = 1
			    	var Index = parent.layer.getFrameIndex(window.name);
			        parent.layer.close(Index);
				}
			})
		}
	    //打印按钮
	    function printing(){
	        bdhtml = window.document.body.innerHTML;
	        phtnl = window.document.getElementById("printinghtml").innerHTML;
	        window.document.body.innerHTML = phtnl; //把需要打印的指定内容赋给big
	        window.print(); //调用浏览器的打印功能打印指定区域
	        window.document.body.innerHTML=bdhtml; // 最后还原页面
	    }
	</script>
</html>
